package com.leyou.page.web;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * lcd  2020/6/12
 * Description:
 */
@Controller
public class PageController {
    @Autowired
    private PageService pageService;

    @RequestMapping("/item/{id}.html")
    public String toItemPage(Model model, @PathVariable("id") long spuId){
        Map<String,Object> attributes=pageService.loadModel(spuId);
        model.addAllAttributes(attributes);
        return "item";
    }

    @RequestMapping("/item/test")
    @ResponseBody
    public void test(){
        pageService.createHtml(141L);
    }
}
